package com.chinanet.repository.faultanticipate.manager;


import com.chinanet.entry.faultanticipate.manager.Associate;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;

public interface AssociateRepository extends PagingAndSortingRepository<Associate, Long> {
    @RestResource(path = "belong", rel = "belong")
    @Query(value = "select * from associate where relation_id=:id", nativeQuery = true)
    Page<Associate> getByBelong(@Param("id") int id, Pageable pageable);

    @RestResource(path = "all", rel = "all")
    @Query(value = "select * from associate", nativeQuery = true)
    Page<Associate> all(Pageable pageable);
}